package com.admission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.admission.dao.SchoolIntrDao;
import com.admission.model.SchoolIntr;

@Transactional
@Repository
public class SchoolIntrManager {
	private SchoolIntrDao schoolIntrDao;
	
	public SchoolIntr getByType(String type){
		List<SchoolIntr> all = schoolIntrDao.findBy("type", type);
		if(all.isEmpty()){
			return null;
		}else{
			return schoolIntrDao.findBy("type", type).get(0);
		}
	}
	
	public SchoolIntr getById(String id){
		return schoolIntrDao.get(id);
	}
	
	public void save(SchoolIntr entity){
		schoolIntrDao.save(entity);
	}

	@Autowired
	public void setSchoolIntrDao(SchoolIntrDao schoolIntrDao) {
		this.schoolIntrDao = schoolIntrDao;
	}
}
